package net.infamily.logic.impl;

import net.infamily.dao.ProfileDao;
import net.infamily.logic.FamilyLogic;
import net.infamily.logic.ProfileLogic;
import net.infamily.model.Family;
import net.infamily.model.Profile;

import com.google.inject.Inject;
import com.google.inject.persist.Transactional;

public class ProfileLogicImpl implements ProfileLogic {
	
	@Inject
	private ProfileDao profileDao;
	
	@Inject
	private FamilyLogic familyLogic;
	
	@Override
	@Transactional
	public Profile createEmptyProfile() {
		Family family = familyLogic.createNewFamily();
		Profile profile = new Profile();
		profile.setFamily(family);
		profileDao.persist(profile);
		return profile;		
	}

	@Override
	@Transactional
	public void deleteProfile(Profile profile) {
		profileDao.remove(profile);
	}
}
